﻿/************************************************************************************************************************
 * The input controller. Finger/Mouse abstraction
 * 
 ************************************************************************************************************************/

using UnityEngine;
using System.Collections.Generic;
using System;

public class MoodController : MonoBehaviour
{

//	private Dictionary <int, List<ClickableObject>> interactions;
	
	public enum MoodState
	{
		RELAXED,
		HAPPY,
		SAD,
		EATING,
		BURPING,
	}

	public MoodState currentMood  = MoodState.RELAXED;


	public MoodState GetCurrentMood()
	{
		return currentMood;
	}

	
	// Event triggered when there is a mouse/touch event
	// Classes can subscribe to the following events to be notified
	public static event Action<MoodState> moodChangedCallbackList;
	
	void Start()
	{

	}
	
	void Update(){
		if (Input.GetKeyDown (KeyCode.F)){
			ChangeMood(GameController.EnvironmentState.BOTTLE);
		}
		if (Input.GetKeyDown (KeyCode.S)){
			ChangeMood(GameController.EnvironmentState.STILL);
		}
		if (Input.GetKeyDown (KeyCode.U)){
			ChangeMood(GameController.EnvironmentState.UPSIDE_DOWN);
		}
	}
	
	// Add a TouchMoved callback. Can be used for functions that only need to know when user moved the finger
	public void AddMoodChangedCallback(Action<MoodState> moodChangedCallback)
	{
		moodChangedCallbackList += moodChangedCallback;
	}
	
	public void RemoveMoodChangedCallback(Action<MoodState> moodChangedCallback)
	{
		moodChangedCallbackList -= moodChangedCallback;
	}



	public void ChangeMood(GameController.EnvironmentState environmentState)
	{

		switch(environmentState)
		{
		case GameController.EnvironmentState.STILL:
			currentMood = MoodState.RELAXED;
			break;

		case GameController.EnvironmentState.BOTTLE:
			currentMood = MoodState.EATING;
			break;

		case GameController.EnvironmentState.UPSIDE_DOWN:
			currentMood = MoodState.HAPPY;
			break;

		default:
			Debug.LogError("unknown EnvironmentState!");
			break;
			
		}


		Debug.Log("Current mood: " + currentMood);

		if(moodChangedCallbackList != null)
		{
			//TouchBeganCallback.Invoke(pos);
			moodChangedCallbackList(currentMood);
		}

	}





}